home *** CD-ROM | disk | FTP | other *** search
/ Aminet 3 / Aminet 3 - July 1994.iso / Aminet / dev / gui / gengui.lha / GenGui / Examples / back.gui < prev    next >
Encoding:
Text File  |  1994-04-29  |  4.4 KB  |  195 lines

  1.  
  2. #c_source
  3.  
  4. #include <proto/graphics.h>
  5.  
  6. #define RED   1
  7. #define GREEN 2
  8. #define BLUE  3
  9.  
  10. int PaletteHook(struct IntuiMessage *msg);
  11. int RedHook(struct IntuiMessage *msg);
  12. int GreenHook(struct IntuiMessage *msg);
  13. int BlueHook(struct IntuiMessage *msg);
  14.  
  15. /* We cannot write this function here, since some values of the GUI are
  16.    not declared/defined yet, but we need the prototype */
  17.  
  18. int ActiveColor=0;
  19. int Red;
  20. int Green;
  21. int Blue;
  22.  
  23. #end_source
  24.  
  25. ProjectName InnerField
  26.  
  27. HBox
  28.    XSpace INTERWIDTH
  29.    YSpace INTERHEIGHT
  30.  
  31.    vbox
  32.       xchar 3*2
  33.       xpix  2*INTERWIDTH+3*4  // 2 * Spacing + 3 Sliders
  34.  
  35.       hbox
  36.          Slider
  37.             xchar 2
  38.             xpix  4
  39.             id RED
  40.             hook RedHook
  41.             tags PGA_Freedom,LORIENT_VERT
  42.             tags GTSL_LevelPlace,PLACETEXT_BELOW
  43.             tags GTSL_LevelFormat,(ULONG)"%2ld"
  44.             tags GTSL_MaxLevelLen,2
  45.          end
  46.          Slider
  47.             xchar 2
  48.             xpix  4
  49.             id GREEN
  50.             hook GreenHook
  51.             tags PGA_Freedom,LORIENT_VERT
  52.             tags GTSL_LevelPlace,PLACETEXT_BELOW
  53.             tags GTSL_LevelFormat,(ULONG)"%2ld"
  54.             tags GTSL_MaxLevelLen,2
  55.          end
  56.          Slider
  57.             xchar 2
  58.             xpix  4
  59.             id BLUE
  60.             hook BlueHook
  61.             tags PGA_Freedom,LORIENT_VERT
  62.             tags GTSL_LevelPlace,PLACETEXT_BELOW
  63.             tags GTSL_LevelFormat,(ULONG)"%2ld"
  64.             tags GTSL_MaxLevelLen,2
  65.          end
  66.       end
  67.       vbox
  68.          stdline 1
  69.       end
  70.    end
  71.    palette
  72.       id 0
  73.       hook PaletteHook
  74.       tags GTPA_Depth,2
  75.       tags GTPA_IndicatorWidth,20
  76.    end
  77. end
  78.  
  79.  
  80. #c_source
  81.  
  82. int PaletteHook(struct IntuiMessage *msg)
  83. {
  84.    ULONG rgb;
  85.  
  86.    if(msg) ActiveColor=msg->Code; // This function is also called from
  87.                                   // Custom(), then msg is 0
  88.  
  89.    rgb=GetRGB4(InnerField.Window->WScreen->ViewPort.ColorMap,ActiveColor);
  90.  
  91.    Red=rgb>>8;
  92.    rgb&=0xff;
  93.    Green=rgb>>4;
  94.    rgb&=0xf;
  95.    Blue=rgb;
  96.  
  97.    Gui_SetGadgetAttrs(InnerField_Gadgets[InnerField_RED],InnerField.Window,NULL,
  98.                      GTSL_Level,Red,TAG_DONE);
  99.    Gui_SetGadgetAttrs(InnerField_Gadgets[InnerField_GREEN],InnerField.Window,NULL,
  100.                      GTSL_Level,Green,TAG_DONE);
  101.    Gui_SetGadgetAttrs(InnerField_Gadgets[InnerField_BLUE],InnerField.Window,NULL,
  102.                      GTSL_Level,Blue,TAG_DONE);
  103.  
  104.    /* IMPORTANT! You must store the values also in the "Code" field of the
  105.       Gadinfo structure, or it would not be vailable for resizing */
  106.  
  107. #if 0
  108.    GetInfo(InnerField_Gadgets[InnerField_RED])->Code=Red;
  109.    GetInfo(InnerField_Gadgets[InnerField_GREEN])->Code=Green;
  110.    GetInfo(InnerField_Gadgets[InnerField_BLUE])->Code=Blue;
  111. #endif
  112.  
  113.    return(1);
  114. }
  115.  
  116. int RedHook(struct IntuiMessage *msg)
  117. {
  118.    Red=msg->Code;
  119.    SetRGB4(&InnerField.Window->WScreen->ViewPort,ActiveColor,Red,Green,Blue);
  120.    return(1);
  121. }
  122.  
  123.  
  124. int GreenHook(struct IntuiMessage *msg)
  125. {
  126.    Green=msg->Code;
  127.    SetRGB4(&InnerField.Window->WScreen->ViewPort,ActiveColor,Red,Green,Blue);
  128.    return(1);
  129. }
  130.  
  131. int BlueHook(struct IntuiMessage *msg)
  132. {
  133.    Blue=msg->Code;
  134.    SetRGB4(&InnerField.Window->WScreen->ViewPort,ActiveColor,Red,Green,Blue);
  135.    return(1);
  136. }
  137.  
  138.  
  139. #end_source
  140.  
  141. #c_source
  142.  
  143. int Custom(struct WinInfo *winfo,
  144.                      struct NewGadget *ng,
  145.                      struct GadInfo *gad,
  146.                      int left, int top, int width, int height)
  147. {
  148.    int ret;
  149.  
  150.    if(winfo->Render) {
  151.             SetAPen(winfo->Window->RPort,0);
  152.             RectFill(winfo->Window->RPort,ng->ng_LeftEdge,ng->ng_TopEdge,
  153.                                      ng->ng_LeftEdge+ng->ng_Width-1,
  154.                                      ng->ng_TopEdge+ng->ng_Height-1);
  155.             DrawBevelBox(winfo->Window->RPort,ng->ng_LeftEdge,ng->ng_TopEdge,
  156.                                      ng->ng_Width,ng->ng_Height,
  157.                                      GT_VisualInfo,winfo->Visual,TAG_DONE);
  158.    }
  159.  
  160.    ret=SubGui(winfo,&InnerField,ng->ng_LeftEdge,ng->ng_TopEdge,
  161.                                         ng->ng_Width,ng->ng_Height);
  162.    if(ret==0 && winfo->Mode==MODE_NEW) { // additional initialisation
  163.       PaletteHook(NULL);
  164.    }
  165.    return(ret);
  166. }
  167.  
  168. #end_source
  169.  
  170.  
  171. projectname TestPro
  172.  
  173. vbox
  174.    custom
  175.       custom Custom
  176.       id 99
  177.    end
  178.  
  179.    hbox
  180.       stdline 1
  181.       button
  182.          text "OK"
  183.          id 4
  184.       end
  185.       vbox
  186.       end
  187.       button
  188.          text "Cancel"
  189.          id 5
  190.       end
  191.    end
  192. end
  193.  
  194.  
  195.